package geez.widget;

import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.Image;
import static geez.widget.Geez.withStyle;

public class GImage extends Image {

    public GImage(String url) {
        super(url);
    }

    public GImage id(String id) {
        Geez.withNameAndId(this, id);
        return this;
    }

    public GImage css(String cssClass, String... optionalClasses) {
        withStyle(this, cssClass, optionalClasses);
        return this;
    }

    public GImage border(String value) {
        return attribute("border", value);
    }

    public GImage style(String styleAttribute) {
        return attribute("style", styleAttribute);
    }

    private GImage attribute(String attribute, String value) {
        DOM.setElementAttribute(getElement(), attribute, value);
        return this;
    }

    public GImage visible(boolean visible) {
        setVisible(visible);
        return this;
    }
}
